package com.exam.controller;

import com.exam.entity.ApiResult;
import com.exam.entity.Replay;
import com.exam.serviceimpl.ReplayServiceImpl;
import com.exam.util.ApiResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping(value = {"/replaycontroller"})
public class ReplayController {

    @Autowired
    private ReplayServiceImpl replayService;

    @PostMapping("/addreplay")
    public ResponseEntity<Integer> add(@RequestBody Replay replay) {
        int data = replayService.add(replay);
        return  new ResponseEntity<Integer>(data, HttpStatus.OK);
    }

    @RequestMapping("/replayfindAllById/{messageId}")
    public ResponseEntity<List<Replay>> findAllById(@PathVariable("messageId") Integer messageId) {
        List<Replay> res = replayService.findAllById(messageId);
        return new ResponseEntity<List<Replay>>(res,HttpStatus.OK);
    }
}
